#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <filesystem>

using namespace std;
typedef long long LL;
const LL N = 1e4 + 5;

LL n, m, x, a[N], sum[N];
LL maxl[N];
LL ansl[N];

void solve() {
    for (LL i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + a[i];
    }

    memset(maxl, -0x3f, sizeof maxl);
    memset(ansl, -0x3f, sizeof ansl);

    for (LL len = 1; len <= n; len++)
        for (LL r = len; r <= n; r++)
            maxl[len] = max(maxl[len], sum[r] - sum[r - len]);

    for (LL len = n; len >= 1; len--)
        ansl[len] = max(ansl[len + 1], maxl[len]);

    while (m--) {
        scanf("%lld", &x);
        printf("%lld\n", ansl[x]);
    }
}

int main() {
    // 创建sample目录
    filesystem::create_directory("sample");
    
    // 处理data目录下的所有测试数据
    for(int i = 1; i <= 13; i++) {
        string in_file = "data/guess" + to_string(i) + ".in";
        string out_file = "data/guess" + to_string(i) + ".out";
        
        freopen(in_file.c_str(), "r", stdin);
        freopen(out_file.c_str(), "w", stdout);
        
        scanf("%lld %lld", &n, &m);
        for (LL i = 1; i <= n; i++) {
            scanf("%lld", &a[i]);
        }
        
        solve();
        
        // 如果是第1、2、3组数据，复制到sample目录
        if(i >=11) {
            string sample_in = "sample/guess" + to_string(i) + ".in";
            string sample_out = "sample/guess" + to_string(i) + ".ans";
            filesystem::copy_file(in_file, sample_in, filesystem::copy_options::overwrite_existing);
            filesystem::copy_file(out_file, sample_out, filesystem::copy_options::overwrite_existing);
        }
    }
    
    return 0;
} 